extends layout
block content
  h6(class="badge badge-light")= title
  table(class="table")
    thead
      tr
        th(scope="col") 名称
        th(scope="col") A相电流
        th(scope="col") B相电流
        th(scope="col") C相电流
        th(scope="col") 零序电流
        th(scope="col") 平均电流
        th(scope="col") 热容实际值%
        th(scope="col") 电流不平衡%
        th(scope="col") 控制器状态
    tbody
      each v, k in motors
        tr
          th(scope='row')= v
          td(id='m_' + k + '_0') -
          td(id='m_' + k + '_1') -
          td(id='m_' + k + '_2') -
          td(id='m_' + k + '_3') -
          td(id='m_' + k + '_8') -
          td(id='m_' + k + '_10') -
          td(id='m_' + k + '_16') -
          td(id='m_' + k + '_status') -


append scripts
  script(src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.slim.js')        

  script.
    let uri = 'http://' + document.domain + ':' + location.port + '/';
    var socket = io(uri);
    socket.on('connect', function(){

      socket.on('f1_t4-6_fan', function(msg){
        console.log(msg); 
        let prefix = 'm_' + msg.id;
        let data = msg.data;
        for (let [k,v] of Object.entries(data)) {
          if ($('#' + prefix + '_' + k).length <= 0) {
            continue;
          }

          $('#' + prefix + '_' + k).html(v);
        }  // for
        $('#' + prefix + '_status').html(msg.status);

      });
    });